#!/bin/bash
# 测试小红书文案提取功能脚本

# 获取脚本所在目录
cd "$(dirname "$0")"

# 激活虚拟环境
source venv/bin/activate

# 设置Python路径
export PYTHONPATH="$PWD/src:$PYTHONPATH"

echo "🧪 测试小红书文案提取功能..."

# 测试URL
TEST_URL="https://www.xiaohongshu.com/explore/688356e50000000010011ea4?xsec_token=ABWv6I5sMSEw7sHKEiAGWk-GJiNYauwfrigG6EJsORoDI=&xsec_source=pc_feed"

echo "📋 测试URL: $TEST_URL"

# 方式1: 直接调用API测试
echo ""
echo "方式1: 测试API接口 /api/media/test/platform_compare"
curl -X GET "http://localhost:8083/api/media/test/platform_compare?url=${TEST_URL}" \
    -H "Accept: application/json" \
    | python3 -m json.tool

echo ""
echo "方式2: 测试提取媒体内容接口 (基础信息)"
curl -X POST "http://localhost:8083/api/media/extract/web" \
    -H "Content-Type: application/json" \
    -H "auth-key: sk-v9" \
    -d "{\"url\": \"$TEST_URL\", \"extract_text\": false}" \
    | python3 -m json.tool

echo ""
echo "方式3: 测试提取媒体内容接口 (包含文案)"
curl -X POST "http://localhost:8083/api/media/extract/web" \
    -H "Content-Type: application/json" \
    -H "auth-key: sk-v9" \
    -d "{\"url\": \"$TEST_URL\", \"extract_text\": true}" \
    | python3 -m json.tool

echo ""
echo "✅ 测试完成"